package com.yjy.shmily;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.qpg.superhttp.utils.GsonUtil;
import com.yjy.mybase.activity.BaseActivity;
import com.yjy.mybase.http.CustomCallback;
import com.yjy.mybase.http.SuperHttpHelper;
import com.yjy.mybase.model.BaseBean;
import com.yjy.mybase.utils.ARouterUri;
import com.yjy.mybase.utils.ToastUtils;

import java.util.HashMap;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = ARouterUri.ACTIVITY_REGISTER)
public class RegisterActivity extends BaseActivity {
    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.et_pwd)
    EditText etPwd;
    private String mPhone,mPwd;

    @Override
    public int layout() {
        return R.layout.activity_register;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
    }
    @OnClick({ R.id.btn_register})
    public void onClickView(View view) {
        switch (view.getId()) {
            case R.id.btn_register:
                register();
                break;
        }
    }
    private void register(){
        mPhone=etPhone.getText().toString().trim();
        mPwd=etPwd.getText().toString().trim();
        if(TextUtils.isEmpty(mPhone) || TextUtils.isEmpty(mPwd)){
            return;
        }
        HashMap<String,String> map=new HashMap<>();
        map.put("phone",mPhone);
        map.put("password",mPwd);
        SuperHttpHelper.superHttpHelper().post("auth/register",map, new CustomCallback<BaseBean<String>>() {
            @Override
            public void success(BaseBean<String> hashMapBaseBean) {
                ToastUtils.show("注册成功");
                finish();
            }
        });
    }
}
